<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- <script>

        // 把字符串"the-first-name" 变成 "theFirstName"

        var str = 'the-first-name';
        var reg = /-(\w)/g;
        console.log(str.replace(reg, function($, $1){
            // 子表达式才能用$,             这里必须写上$, $1两个，考虑实参列表
            return $1.toUpperCase();
        }));



        var str = "abaaaa";
        var reg = /a(?=b)/g;   // 匹配a，但a的后面有b修饰，b并不参与匹配
        var reg1 = /a(?!b)/g;  // 匹配后面不是b的a 

        console.log(str.match(reg)); // 只返回第一个a
        console.log(str.match(reg1)); 

    </script> -->

    <script>

        var str = "aaaaaaaaaaabbbbbbbbbbbbbccccccccdddddddddffffaaaaaaaa";
        var reg = /(\w)\1*/g;  // *就是\1出现0到无数次
        console.log(str.replace(reg, "$1"));

        var str1 = "1214536456547567868";
        var reg1 = /(?=\B(\d{3})+$)/g;
        console.log(str1.replace(reg1, ".")); // '100.000.000'


        console.log(reg1.exec(str1));
    </script>

    <script>

        var str2 = 'abcd';
        var reg2 = /(?=[\w\W]*)/g;
        console.log(str2.match(reg2)); // 用于匹配空串的写法


    </script>

</body>
</html>